package com.ly.video.common.config;

import com.ly.video.common.interceptor.RequestInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class AppConfig implements WebMvcConfigurer {


    @Autowired
    private RequestInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry){
        List<String> patterns = new ArrayList<>();
        patterns.add("/");
        registry.addInterceptor(tokenInterceptor).addPathPatterns(patterns);  // token 验证拦截器
    }
}
